using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.UI;

public class EditorUtilityTest_Dirty
{
    [MenuItem("Assets/EditorUtilityTest/Dirty/ChangeColor")]
    public static void ChangeGameObject()
    {
        if(Selection.gameObjects!=null
            &&Selection.gameObjects.Length == 1)
        {
            var go = Selection.gameObjects[0];
            go.GetComponent<Image>().color = Color.red;
            var child = go.transform.GetChild(0);
            //EditorUtility.SetDirty(child.gameObject);
            EditorUtility.SetDirty(go);
            EditorUtility.ClearDirty(go);
            EditorUtility.IsDirty(go.GetInstanceID());
            Debug.Log(EditorUtility.GetDirtyCount(go.GetInstanceID()));
            //EditorUtility.ClearDirty(go);
            //AssetDatabase.SaveAssets();
            //AssetDatabase.Refresh();
            //Debug.Log(EditorUtility.GetDirtyCount(go.GetInstanceID()));
        }
    }
}
